{% extends "admin/layout.html" %}
{% block title %}{{ title }}{% endblock %}
{% if post.created %}
{% set posts_active = 'active' %}
{% else %}
{% set post_active = 'active' %}
{% endif %}

{% block header %}
<link type="text/css" rel="stylesheet" media="all" href="/static/js/jscalendar-1.0/calendar-system.css" />
<script type="text/javascript" src="/static/js/jscalendar-1.0/calendar_stripped.js"></script>
<script type="text/javascript" src="/static/js/jscalendar-1.0/calendar-setup_stripped.js"></script>
<script type="text/javascript" src="/static/js/jscalendar-1.0/lang/cn_utf8.js"></script>

<script type="text/javascript" src="/tinymce/tiny_mce.js"></script>
<script type="text/javascript">
function mediaBrowser(field_name, url, type, win) {
  tinyMCE.activeEditor.windowManager.open({
    file : '/admin/media',
    title : 'Media',
    width : 770,
    height : 480,
    resizable : "yes",
		scrollbars : "yes",
    inline : "yes",
    close_previous : "no"
  }, {
    window : win,
    input : field_name
  });
  return false;
}

tinyMCE.init({
  mode : "exact",
  elements : "content",
  width : "100%",
  height : "300",
  language : "zh",
  plugins: "table,advimage,advlink,paste,searchreplace,inlinepopups,fullscreen,preelementfix",
  file_browser_callback : "mediaBrowser",
  theme: "advanced",
  theme_advanced_toolbar_location: "top",
  theme_advanced_toolbar_align: "left",
  theme_advanced_statusbar_location : "bottom",
  theme_advanced_resizing : true,
  theme_advanced_resize_horizontal : false,
  extended_valid_elements : "code[name|class],pre[name|class|style]",
  theme_advanced_buttons1:
  "justifyleft,justifycenter,justifyright,justifyfull,|,bold,italic,strikethrough,|,forecolor,backcolor,|,sub,sup,|,charmap|,formatselect,fontsizeselect",
  theme_advanced_buttons2:
  "bullist,numlist,|,outdent,indent,|,search,replace,|,undo,redo,|,link,unlink,image,flash,|,paste,pastetext,pasteword,|,cleanup,removeformat,|,fullscreen,|,code",
  theme_advanced_buttons3: "",
  relative_urls: false,
  debug: false
});
</script>
{% endblock %}

{% block content %}
<div id="containerHolder">
  <div id="container">
    <div id="sidebar">
      <ul class="sideNav">
        <li><a href="/admin/posts">日志管理</a></li>
      </ul>
    </div>
    <h2><a href="#">Dashboard</a> &raquo; <a href="#" class="active">{{ title }}</a></h2>

    <div id="main">
      <h3>{{ title }}：</h3>
      <form action="" method="post">
        <fieldset>
          <p><label class="caption">标题：</label><input id="id_title" type="text" class="title" value="{{ post.title }}" name="title" /></p>
          <p>
            <label style="font-weight:bold;">分类：</label>
            <select name="category" style="min-width:100px;max-width:130px;">
              <option value=""></option>
              {% for category in categories %}
              <option value="{{ category.key() }}"{% if post.category and post.category.key() == category.key() %} selected="selected"{% endif %}>{{ category.name }}</option>
              {% endfor %}
            </select>
            <label style="font-weight:bold;">发布时间：</label>
            <input id="id_date" name="date" type="text" readonly="readonly" class="text-medium" value="{{ post.date|date("%Y-%m-%d %H:%M:%S") }}" />
            <script type="text/javascript">
              Calendar.setup({
                inputField  : "id_date",
                ifFormat    : "%Y-%m-%d %H:%M:%S",
                showsTime   : true,
                button      : "id_date"
              });
            </script>
            <label style="font-weight:bold;">文章别名：</label>
            <input id="id_alias" name="alias" type="text" class="text-medium" value="{{ post.alias }}" />
          </p>
          <p>
            <label class="caption">内容：</label>
            <a href="#" onclick="mediaBrowser();return false;">插入媒体</a>
            <textarea id="id_content" rows="10" cols="40" name="content">{{ post.content|e }}</textarea>
          </p>
          <p><label class="caption">Tags：</label><input type="text" size="50" id="id_tags" class="text-long" value="{{ post.taglist|e }}" name="tags"/></p>
          <p><label class="caption">摘要：</label><textarea id="id_excerpt" style="width:650px;height:70px" rows="10" cols="40" name="excerpt">{{ post.excerpt }}</textarea></p>
          <p>
            <label class="caption">高级选项：</label>
            <label><input type="checkbox" name="allow_comment" id="id_allow_comment"{% if post.allow_comment != False %} checked="checked"{% endif %} /> 允许评论</label>
            <label><input type="checkbox" name="allow_ping" id="id_allow_ping"{% if post.allow_ping != False %} checked="checked"{% endif %} /> 允许引用</label>
            <label><input type="checkbox" name="hidden" id="id_hidden"{% if post.hidden == True %} checked="checked"{% endif %} /> 隐藏</label>
          </p>
          <input type="submit" value=" 发 布 " />
        </fieldset>
      </form>
    </div>
    <div class="clear"></div>
  </div>
</div>
{% endblock %}